const Base = require('./base.js');

module.exports = class extends Base {
  async indexAction() {
    const posts = await think.model('contents').alias('c').field('c.*, m.name as metas_name').where({ 'c.type': 'post' }).order('`order` DESC').join({
      table: 'metas',
      join: 'inner',
      as: 'm',
      on: ['mid', 'mid']
    }).select();
    posts.map(post => {
      post.created = think.datetime(post.created * 1000);
      return post;
    });
    this.assign('posts', posts);
    return this.display();
  }
};
